fix(openai-agents): add MCPListToolsSpanData support (#4197)#4
Closed
nagkumar91 wants to merge 1 commit into
Closed
fix(openai-agents): add MCPListToolsSpanData support (#4197)#4nagkumar91 wants to merge 1 commit into
nagkumar91 wants to merge 1 commit into
Conversation
…4197) The OpenAI Agents SDK emits MCPListToolsSpanData spans when fetching MCP server tool lists, but the instrumentation did not recognize this type, producing "unknown" spans with no data. Adds MCPListToolsSpanData handling with proper operation name (mcp.list_tools), span kind (CLIENT), and attribute extraction (mcp.server.name, mcp.tools.count, mcp.tools.list). Also adds a generic .type-based fallback so future unrecognized SDK span types get a meaningful name instead of "unknown". Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes open-telemetry#4197 — MCP List Tools spans show only as 'unknown' with no data.
Problem
The OpenAI Agents SDK emits
MCPListToolsSpanDataspans (withtype="mcp_tools") when fetching MCP server tool lists, but the OTel instrumentation didn't import or handle this type, causing these spans to getoperation_name="unknown"with no useful attributes.Changes
MCPListToolsSpanDatain both thetryandexceptimport blocks inspan_processor.py"mcp.list_tools"forMCPListToolsSpanDataSpanKind.CLIENT(MCP server interaction is a client call)mcp.server.name,mcp.tools.count, andmcp.tools.list(sensitive)span_data.typefor future unrecognized SDK span types instead of"unknown"MCPListToolsSpanDatadataclass withserver,result, andtypefieldsTesting
All 104 tests pass, including the new
test_mcp_list_tools_spantest.